package com.example.demotest.demotest.handler;

import com.example.demotest.demotest.aspect.AnnotationRange;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.HashSet;

/**
 * @author x_weidanlang
 * @version 1.0
 * @date 2022/2/9 10:36
 *
 * ConstraintValidatorConstraintValidator<AnnotationRange,Integer>，第二个参数类型与vo中要校验的类型一致，如果vo中是String，那么这里就是String
 */

public class AnnotationRangeValidatorHandler implements ConstraintValidator<AnnotationRange,Integer> {
    @Override
    public boolean isValid(Integer s, ConstraintValidatorContext constraintValidatorContext) {
        HashSet<Object> regions=new HashSet<>();
        regions.add(1);
        regions.add(2);
        regions.add(3);
        regions.add(4);
        return regions.contains(s);
    }

}
